package Question6;

import java.util.Stack;

/**
 * Created by lenovo on 2017/3/7.
 */
public class Question6 {
    public static boolean isGoodBracket(String s){
        Stack<Character> stack = new Stack<>();
        char[] chars = s.toCharArray();

        for(int i=0;i<chars.length;i++){
            if(chars[i]=='['||chars[i]=='('||chars[i]=='{'){
                stack.push(chars[i]);
            }else if(chars[i]==']'&&stack.peek().equals('[')){
                stack.pop();
            }else if(chars[i]==')'&&stack.peek().equals('(')){
                stack.pop();
            }else if(chars[i]=='}'&&stack.peek().equals('{')){
                stack.pop();
            }
        }

        if(stack.size()==0){
            return true;
        }
        return false;
    }
    public  static void main(String[] args){
      if(Question6.isGoodBracket("..(..[..)..)..")){
          System.out.println("true");
      }else {
          System.out.println("false");
      }
    }
}
